gtk_file_chooser_set_create_folders
gtk_file_chooser_get_create_folders
gtk_file_chooser_set_current_name
+gtk_file_chooser_get_current_name
gtk_file_chooser_get_filename
gtk_file_chooser_set_filename
gtk_file_chooser_select_filename
GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
}
+/**
+ * gtk_file_chooser_get_current_name:
+ * @chooser: a #GtkFileChooser
+ *
+ * Gets the current name in the file selector, as entered by the user in the
+ * text entry for "Name".
+ *
+ * This is meant to be used in save dialogs, to get the currently typed filename
+ * when the file itself does not exist yet. For example, an application that
+ * adds a custom extra widget to the file chooser for "file format" may want to
+ * change the extension of the typed filename based on the chosen format, say,
+ * from ".jpg" to ".png".
+ *
+ * Returns: The raw text from the file chooser's "Name" entry. Free this with
+ * g_free(). Note that this string is not a full pathname or URI; it is
+ * whatever the contents of the entry are. Note also that this string is in
+ * UTF-8 encoding, which is not necessarily the system's encoding for filenames.
+ *
+ * Since: 3.10
+ **/
+gchar *
+gtk_file_chooser_get_current_name (GtkFileChooser *chooser)
+{
+ g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+
+ return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_name (chooser);
+}
+
/**
* gtk_file_chooser_get_uri:
* @chooser: a #GtkFileChooser
/* Suggested name for the Save-type actions
*/
GDK_AVAILABLE_IN_ALL
-void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
- const gchar *name);
+void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
+ const gchar *name);
+GDK_AVAILABLE_IN_3_10
+gchar *gtk_file_chooser_get_current_name (GtkFileChooser *chooser);
/* Filename manipulation
*/
static GFile * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser);
static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
const gchar *name);
+static gchar * gtk_file_chooser_default_get_current_name (GtkFileChooser *chooser);
static gboolean gtk_file_chooser_default_select_file (GtkFileChooser *chooser,
GFile *file,
GError **error);
iface->set_current_folder = gtk_file_chooser_default_set_current_folder;
iface->get_current_folder = gtk_file_chooser_default_get_current_folder;
iface->set_current_name = gtk_file_chooser_default_set_current_name;
+ iface->get_current_name = gtk_file_chooser_default_get_current_name;
iface->add_filter = gtk_file_chooser_default_add_filter;
iface->remove_filter = gtk_file_chooser_default_remove_filter;
iface->list_filters = gtk_file_chooser_default_list_filters;
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), name);
}
+static gchar *
+gtk_file_chooser_default_get_current_name (GtkFileChooser *chooser)
+{
+ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+ GtkFileChooserDefaultPrivate *priv = impl->priv;
+
+ g_return_val_if_fail (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
+ NULL);
+
+ return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->location_entry)));
+}
+
static gboolean
gtk_file_chooser_default_select_file (GtkFileChooser *chooser,
GFile *file,
GFile * (*get_current_folder) (GtkFileChooser *chooser);
void (*set_current_name) (GtkFileChooser *chooser,
const gchar *name);
+ gchar * (*get_current_name) (GtkFileChooser *chooser);
gboolean (*select_file) (GtkFileChooser *chooser,
GFile *file,
GError **error);
static GFile * delegate_get_current_folder (GtkFileChooser *chooser);
static void delegate_set_current_name (GtkFileChooser *chooser,
const gchar *name);
+static gchar * delegate_get_current_name (GtkFileChooser *chooser);
static gboolean delegate_select_file (GtkFileChooser *chooser,
GFile *file,
GError **error);
iface->set_current_folder = delegate_set_current_folder;
iface->get_current_folder = delegate_get_current_folder;
iface->set_current_name = delegate_set_current_name;
+ iface->get_current_name = delegate_get_current_name;
iface->select_file = delegate_select_file;
iface->unselect_file = delegate_unselect_file;
iface->select_all = delegate_select_all;
gtk_file_chooser_set_current_name (get_delegate (chooser), name);
}
+static gchar *
+delegate_get_current_name (GtkFileChooser *chooser)
+{
+ return gtk_file_chooser_get_current_name (get_delegate (chooser));
+}
+
static void
delegate_notify (GObject *object,
GParamSpec *pspec,